import * as actions from '../actions/paragraph'
import { COMMANDS } from '../../commands'

export default function (keybindings, language) {
  return {
    id: 'paragraphMenuEntry',
    label: language.getString('paragraph'),
    submenu: [{
      id: 'heading1MenuItem',
      label: language.getString('heading1'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HEADING_1),
      click (menuItem, focusedWindow) {
        actions.heading1(focusedWindow)
      }
    }, {
      id: 'heading2MenuItem',
      label: language.getString('heading2'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HEADING_2),
      click (menuItem, focusedWindow) {
        actions.heading2(focusedWindow)
      }
    }, {
      id: 'heading3MenuItem',
      label: language.getString('heading3'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HEADING_3),
      click (menuItem, focusedWindow) {
        actions.heading3(focusedWindow)
      }
    }, {
      id: 'heading4MenuItem',
      label: language.getString('heading4'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HEADING_4),
      click (menuItem, focusedWindow) {
        actions.heading4(focusedWindow)
      }
    }, {
      id: 'heading5MenuItem',
      label: language.getString('heading5'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HEADING_5),
      click (menuItem, focusedWindow) {
        actions.heading5(focusedWindow)
      }
    }, {
      id: 'heading6MenuItem',
      label: language.getString('heading6'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HEADING_6),
      click (menuItem, focusedWindow) {
        actions.heading6(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'upgradeHeadingMenuItem',
      label: language.getString('promoteHeading'),
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_INCREASE_HEADING),
      click (menuItem, focusedWindow) {
        actions.increaseHeading(focusedWindow)
      }
    }, {
      id: 'degradeHeadingMenuItem',
      label: language.getString('demoteHeading'),
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_DEGRADE_HEADING),
      click (menuItem, focusedWindow) {
        actions.degradeHeading(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'tableMenuItem',
      label: language.getString('table'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_TABLE),
      click (menuItem, focusedWindow) {
        actions.table(focusedWindow)
      }
    }, {
      id: 'codeFencesMenuItem',
      label: language.getString('codeFences'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_CODE_FENCE),
      click (menuItem, focusedWindow) {
        actions.codeFence(focusedWindow)
      }
    }, {
      id: 'quoteBlockMenuItem',
      label: language.getString('quoteBlock'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_QUOTE_BLOCK),
      click (menuItem, focusedWindow) {
        actions.quoteBlock(focusedWindow)
      }
    }, {
      id: 'mathBlockMenuItem',
      label: language.getString('mathBlock'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_MATH_FORMULA),
      click (menuItem, focusedWindow) {
        actions.mathFormula(focusedWindow)
      }
    }, {
      id: 'htmlBlockMenuItem',
      label: language.getString('htmlBlock'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HTML_BLOCK),
      click (menuItem, focusedWindow) {
        actions.htmlBlock(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'orderListMenuItem',
      label: language.getString('orderedList'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_ORDERED_LIST),
      click (menuItem, focusedWindow) {
        actions.orderedList(focusedWindow)
      }
    }, {
      id: 'bulletListMenuItem',
      label: language.getString('bulletList'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_BULLET_LIST),
      click (menuItem, focusedWindow) {
        actions.bulletList(focusedWindow)
      }
    }, {
      id: 'taskListMenuItem',
      label: language.getString('taskList'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_TASK_LIST),
      click (menuItem, focusedWindow) {
        actions.taskList(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'looseListItemMenuItem',
      label: language.getString('looseListItem'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_LOOSE_LIST_ITEM),
      click (menuItem, focusedWindow) {
        actions.looseListItem(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'paragraphMenuItem',
      label: language.getString('paragraph'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_PARAGRAPH),
      click (menuItem, focusedWindow) {
        actions.paragraph(focusedWindow)
      }
    }, {
      id: 'horizontalLineMenuItem',
      label: language.getString('horizontalRule'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_HORIZONTAL_LINE),
      click (menuItem, focusedWindow) {
        actions.horizontalLine(focusedWindow)
      }
    }, {
      id: 'frontMatterMenuItem',
      label: language.getString('frontMatter'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.PARAGRAPH_FRONT_MATTER),
      click (menuItem, focusedWindow) {
        actions.frontMatter(focusedWindow)
      }
    }]
  }
}
